package com.yyj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yyj.mapper.StudentMapper;
import com.yyj.pojo.entity.Student;
import com.yyj.pojo.vo.StudentVo;
import com.yyj.service.StudentService;
import com.yyj.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @program: qy164-springboot4
 * @description:
 * @author: 杨英俊
 * @create: 2023-04-12 19:42
 **/
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public Result findByPages(Integer current, Integer pageSize, StudentVo studentVo) {
        Page<Student> pag=new Page<>(current,pageSize);
        QueryWrapper<Student> wrapper=new QueryWrapper<>();
        if (StringUtils.hasText(studentVo.getSname())){
            wrapper.like("sname",studentVo.getSname());
        }
        IPage<Student> selectpages = studentMapper.selectpages(pag, wrapper);
        return new Result(200,"分页条件查询成功",selectpages);
    }


}
